<template>
    <div>
        <el-row style="margin: 10px 20px 10px 10px;">
            <el-input v-model="rowdata.year" placeholder="请输入内容" :disabled="true"  style="margin-left: 30px;width: 120px;">
                <template slot="append">年</template>
            </el-input>
        </el-row>
        <el-table style="width:92%" :data="dfsyrecoderTrue"  border  :empty-text="showemptytext" >
            <el-table-column  width="65" label="标识" :show-overflow-tooltip='true' align="center">
                <template slot-scope="scope">
                    <img class="default-image" :src="$store.state.images.wujiaoxing" style="width：45px;height:45px;"> 
                </template> 
            </el-table-column>
            <el-table-column type="index" width="120" label="序号"  :index="indexbf" :show-overflow-tooltip='true'  align="center">
            </el-table-column>
            <el-table-column prop="time" width="80" label="支出时间"   :show-overflow-tooltip='true'  align="center"></el-table-column>
            <el-table-column prop="dwname" width="305" label="党委名称" :show-overflow-tooltip='true'  align="center" ></el-table-column>
            <el-table-column prop="money" width="85" label="支出金额" :show-overflow-tooltip='true'  align="center"></el-table-column>
            <el-table-column prop="lingdao" width="125" label="主管领导" :show-overflow-tooltip='true'  align="center"></el-table-column>
            <el-table-column prop="jingbanren" width="85" label="经办人" :show-overflow-tooltip='true'  align="center"></el-table-column>
            <el-table-column prop="reason" width="85" label="支出原因" :show-overflow-tooltip='true'  align="center"></el-table-column>
            <el-table-column align="right">
                <template slot="header" slot-scope="scope">
                    <el-button  size="mini"    @click="serchdf">查询</el-button>
                    <el-button  size="mini"  @click="adddfsy" v-show="ZongShow">新增</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination @changed="showdfsyRecoderstrue" :recoder="dfsyrecoder"> </pagination>
        <dfshiyongadd ref='dfshiyongadd' v-on:editResult="serchdf"></dfshiyongadd>
    </div>
</template>
<script>
import {mapActions} from 'vuex';
    export default {
        data() {
            return { 
                dialogVisible: false, 
                rowdata:{
                    year:'2018',
                }, 
                dfsyrecoder:[],
                dfsyrecoderTrue:[],
                offset:0,
                ZongShow:false,//当进入局级别时 才可以添加党费使用
                default_emptytext:"请点击右侧查询记录",
                showemptytext:'',
            };
            
        },
        mounted() {
            if(this.GetUser()==false){
                this.$router.push("/");
            }
            this.GetActiveDwId_DzbId();
            if(this.$store.state.Dw_DzbID.dwid==-1){
                this.ZongShow=true;
            }
            else if(this.$store.state.Dw_DzbID.dzbid==-1){
                this.ZongShow=false;
            }
            else{
                this.ZongShow=false;
            }
        },
        watch: {
        },
        components: {
            dfshiyongadd: function(resolve) {require(["./dfshiyongadd.vue"], resolve);},
        },
        methods: {
            ...mapActions(['GetUser','GetActiveDwId_DzbId']),
            showdfsyRecoderstrue(showrecoders,offset){
                this.dfsyrecoderTrue=showrecoders;
                this.offset=offset;
            },
            indexbf(index){return index+this.offset+1;},
            serchdf()
            {
                this.dfsyrecoder=[];
                let _this=this;
                let data={
                    // dwid:this.$store.state.Dw_DzbID.dwid,
                    // dzbid:this.$store.state.Dw_DzbID.dzbid,
                    year:this.rowdata.year,
                }
                let postdata={
                    type:"serchdangfeisy",
                    split:JSON.stringify(data)
                }
                _this.$Common.AjaxPost(postdata,true)
                .then(function(e){
                    if(e.dfeisys.length==0){
                        _this.showemptytext='没有找到记录';
                        setTimeout(() => {
                            _this.showemptytext=_this.default_emptytext;
                        }, 1000);
                    }
                    else{
                        _this.dfsyrecoder=e.dfeisys; 
                    }
                });
            },
            adddfsy()
            {
                this.$refs.dfshiyongadd.$data.dialogVisible = true;
                this.$refs.dfshiyongadd.$data.year = this.rowdata.year;
            },
        },
    }
</script>